From: Keir Fraser Date: Wed, 22 Oct 2008 10:58:20 +0000 (+0100) Subject: x86, hap: Track max_mapped_pfn better when using 2MB p2m mappings. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14054^2~57 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=a326f234ae90ef49c95b5b9a09e626685741c264;p=xen.git x86, hap: Track max_mapped_pfn better when using 2MB p2m mappings. The test for when to increase it was not quite right; also on EPT the value it was set to didn't count the top 511 frames. Signed-off-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/hap/p2m-ept.c b/xen/arch/x86/mm/hap/p2m-ept.c index 8ed9c08f1f..689f152261 100644 --- a/xen/arch/x86/mm/hap/p2m-ept.c +++ b/xen/arch/x86/mm/hap/p2m-ept.c @@ -157,9 +157,6 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, { if ( mfn_valid(mfn_x(mfn)) || (p2mt == p2m_mmio_direct) ) { - /* Track the highest gfn for which we have ever had a valid mapping */ - if ( gfn > d->arch.p2m->max_mapped_pfn ) - d->arch.p2m->max_mapped_pfn = gfn; ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn)); ept_entry->sp_avail = walk_level ? 1 : 0; @@ -234,6 +231,11 @@ ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, unmap_domain_page(split_table); } + /* Track the highest gfn for which we have ever had a valid mapping */ + if ( mfn_valid(mfn_x(mfn)) + && (gfn + (1UL << order) - 1 > d->arch.p2m->max_mapped_pfn) ) + d->arch.p2m->max_mapped_pfn = gfn + (1UL << order) - 1; + /* Success */ rv = 1; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 24957e00b4..93f9489559 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -322,7 +322,8 @@ p2m_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn, } /* Track the highest gfn for which we have ever had a valid mapping */ - if ( mfn_valid(mfn) && (gfn > d->arch.p2m->max_mapped_pfn) ) + if ( mfn_valid(mfn) + && (gfn + (1UL << page_order) - 1 > d->arch.p2m->max_mapped_pfn) ) d->arch.p2m->max_mapped_pfn = gfn + (1UL << page_order) - 1; if ( iommu_enabled && (is_hvm_domain(d) || need_iommu(d)) )